(() => {
  const position = "absolute";
  class Food {
    constructor(options) {
      options = options || {};
      this.width = options.width || 20;
      this.height = options.height || 20;
      this.x = options.x || 0;
      this.y = options.y || 0;
      this.color = options.color || "black";
      this.length = options.length || 3;
      this.position = position;
      this.elemntArr = [];
    }
    render(map) {
      const div = document.createElement("div");
      this.x =
        Tools.getRandom(0, map.clientWidth / this.width - 1) * this.width;
      this.y =
        Tools.getRandom(0, map.clientHeight / this.height - 1) * this.height;
      div.style.width = this.width + "px";
      div.style.height = this.height + "px";
      div.style.backgroundColor = this.color;
      div.style.position = this.position;
      div.style.left = this.x + "px";
      div.style.top = this.y + "px";
      map.appendChild(div);
      this.elemntArr.push(div);
      // console.log(this.elemntArr)
    }
    remove(map, i) {
      map.removeChild(this.elemntArr[i]);
      this.elemntArr.splice(i, 1);
    }
  }
  window.Food = Food;
})();
